package com.example.canteen.controller;
import com.example.canteen.domain.Products;
import com.example.canteen.domain.PurchaseOrders;
import com.example.canteen.service.ProductsService;
import com.example.canteen.service.PurchaseOrdersService;
import com.example.canteen.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController

@RequestMapping("/purchaseOrders")
@Api(tags = "采购订单管理(0304 高凯)")
//@Anonymous
public class PurchaseOrdersController {
    @Autowired
    PurchaseOrdersService service;
    @GetMapping("/getPurchaseOrdersListAll")
    @ApiOperation(value = "获取所有采购订单列表")
    public AjaxResult getPurchaseOrdersListAll() {
        System.out.println(service.selectAllPurchaseOrders());
        return AjaxResult.success(service.selectAllPurchaseOrders());
    };
    @GetMapping("/getPurchaseOrdersById")
    @ApiOperation(value = "根据id查询采购订单信息")
    public AjaxResult getPurchaseOrdersById(int id) {
        System.out.println(service.selectPurchaseOrdersById(id));
        return AjaxResult.success(service.selectPurchaseOrdersById(id));
    }
    @PostMapping("/insertPurchaseOrders")
    @ApiOperation(value = "新增采购订单")
    public AjaxResult addSuppliers(@RequestBody PurchaseOrders purchaseorders) {
        return AjaxResult.success(service.insertPurchaseOrders(purchaseorders));
    }
    @DeleteMapping("/DeletePurchaseOrders")
    @ApiOperation(value = "删除采购订单")
    public AjaxResult DeletePurchaseOrders(int id) {
        return AjaxResult.success(service.deletePurchaseOrdersByID(id));
    }
}
